package com.bussiness;
import com.exceptions.*;

import javax.jws.WebService;

import com.beans.Movie;
import com.beans.Person;

import com.dao.AdminDAO;
import com.dao.moviedao;


@WebService
public class AdminBussiness 
{
	public AdminBussiness()
	{
		
	}
	public Person[] getAllPremiumMembers() throws ServiceUnavailableException
	{
		Person[] PremiumMemberList = null;
		AdminDAO admin=new AdminDAO();
		
		try
		{
			PremiumMemberList=admin.getAllPremiumMembers();
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.out.println("\n Service is unavailable.");
			throw new ServiceUnavailableException();	
		
		}
		return PremiumMemberList;
	}
	
	public Person[] getAllSimpleMembers() throws ServiceUnavailableException
	{
		Person[] SimpleMemberList = null;
		AdminDAO admin=new AdminDAO();
		
		try
		{
			SimpleMemberList=admin.getAllSimpleMembers();
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.out.println("\n Service is unavailable.");
			throw new ServiceUnavailableException();	
		
		}
		return SimpleMemberList;
	}
	
	
	public Person[] getAllMembersByState(String state) throws ServiceUnavailableException
	{
		Person[] allMemberList = null;
		AdminDAO admin=new AdminDAO();
		
		try
		{
			allMemberList=admin.getAllMembersByState(state);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.out.println("\n Service is unavailable.");
			throw new ServiceUnavailableException();	
		
		}
		
		return allMemberList;
	}

	

	public Person[] getAllMembersByCity(String city) throws ServiceUnavailableException
	{
		Person[] allMemberList = null;
		AdminDAO admin=new AdminDAO();
		
		try
		{
			allMemberList=admin.getAllMembersByCity(city);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.out.println("\n Service is unavailable.");
			throw new ServiceUnavailableException();	
		
		}
		
		return allMemberList;
	}
	

	public Person[] getAllMembersByZip(int zip) throws ServiceUnavailableException
	{
		Person[] allMemberList = null;
		AdminDAO admin=new AdminDAO();
		
		try
		{
			allMemberList=admin.getAllMembersByZip(zip);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.out.println("\n Service is unavailable.");
			throw new ServiceUnavailableException();	
		
		}
		
		return allMemberList;
		
	}
	
	public Person[] getAllMembersByFname(String fname) throws ServiceUnavailableException
	{
		Person[] allMemberList = null;
		AdminDAO admin=new AdminDAO();
		
		try
		{
			allMemberList=admin.getAllMembersByFname(fname);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.out.println("\n Service is unavailable.");
			throw new ServiceUnavailableException();	
		
		}
		
		return allMemberList;
	
	}
	
	public Person[] getAllMembersByLname(String lname) throws ServiceUnavailableException
	{
		Person[] allMemberList = null;
		AdminDAO admin=new AdminDAO();
		
		try
		{
			allMemberList=admin.getAllMembersByLname(lname);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.out.println("\n Service is unavailable.");
			throw new ServiceUnavailableException();	
		
		}
		
		return allMemberList;
	
	}
	
	public Person getPersonsById(long memid) throws ServiceUnavailableException
	{
		Person allMemberList = null;
		AdminDAO admin=new AdminDAO();
		
		try
		{
			allMemberList= admin.getAllPersonById(memid);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.out.println("\n Service is unavailable.");
			throw new ServiceUnavailableException();	
		
		}
		
		return allMemberList;
	
	}

	public Movie getMovieByName(String name) throws Exception
	{
		Movie movieList= new Movie();
		
		AdminDAO admindaoObject = new AdminDAO();
		try
		{
			movieList = admindaoObject.getMoviesByName(name);
		}
		catch(ServiceUnavailableException suex)
		{
			suex.printStackTrace();
			System.out.println("\n Service Unavailable.");
			throw suex;	
		}
		return movieList;	
	}

	public Movie getMovieByBanner(String banner) throws Exception
	{
		Movie movieList= new Movie();
		
		AdminDAO AdmindaoObject = new AdminDAO();
		try
		{
			movieList = AdmindaoObject.getMoviesByBanner(banner);
		}
		catch(ServiceUnavailableException suex)
		{
			suex.printStackTrace();
			System.out.println("\n Service Unavailable.");
			throw suex;	
		}
		return movieList;	
	}


	public Movie[] getMovieByReleaseDate(String date) throws Exception
	{
		Movie[] movieList= null;
		
		AdminDAO admindaoObject = new AdminDAO();
		try
		{
			movieList = admindaoObject.getMoviesReleaseDate(date);
		}
		catch(ServiceUnavailableException suex)
		{
			suex.printStackTrace();
			System.out.println("\n Service Unavailable.");
			throw suex;	
		}
		return movieList;	
	}

	public Movie[] getMovieByRent(double rent) throws Exception
	{
		Movie[] movieList= null;
		
		AdminDAO admindaoObject = new AdminDAO();
		try
		{
			movieList = admindaoObject.getMoviesByRent(rent);
		}
		catch(ServiceUnavailableException suex)
		{
			suex.printStackTrace();
			System.out.println("\n Service Unavailable.");
			throw suex;	
		}
		return movieList;	
	}
	
	public Movie[] getMovieByCategory(String category) throws Exception
	{
		Movie[] movieList= null;
		
		AdminDAO admindaoObject = new AdminDAO();
		try
		{
			movieList = admindaoObject.getMoviesByCategory(category);
		}
		catch(ServiceUnavailableException suex)
		{
			suex.printStackTrace();
			System.out.println("\n Service Unavailable.");
			throw suex;	
		}
		return movieList;	
	}
	
}
